@{
    ViewBag.Title = "我的信息";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<style>
    .gray-bg {
        background-color: #ffffff;
    }

</style>
<div class="row">
    <div class="col-sm-6">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>我的个人信息</h5>
            </div>
            <div class="ibox-content">
                <form class="form-horizontal" style="margin-top: 10px;">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">用户姓名：</label>

                        <div class="col-sm-8">
                            <input type="text" v-model="currentRow.UserName"  placeholder="用户姓名" class="form-control" value="@ViewBag.UserName"> <span class="help-block m-b-none">请输入您的姓名</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">联系手机：</label>

                        <div class="col-sm-8">
                            <input type="tel" v-model="currentRow.Phone" placeholder="联系手机" class="form-control" value="@ViewBag.Phone"> <span class="help-block m-b-none">请输入您的联系方式</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-3 col-sm-8">
                            <button class="btn btn-w-m btn-success authorization" style="display: none" action-id="user-detail-update" action-name="更新个人信息" type="button"  v-on:click="_UpdateUserInfo">更新个人信息</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="col-sm-6">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>修改密码</h5>
            </div>
            <div class="ibox-content">
                <form class="form-horizontal" style="margin-top: 10px;">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">旧密码：</label>
                        <div class="col-sm-8">
                            <input type="password" v-model="currentRow.OldPwd"  placeholder="旧密码" class="form-control"> <span class="help-block m-b-none">请输入您的旧密码</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">密码：</label>

                        <div class="col-sm-8">
                            <input type="password" v-model="currentRow.Pwd"  placeholder="密码" class="form-control"><span class="help-block m-b-none">请输入您的新密码</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-3 col-sm-8">
                            <button class="btn btn-w-m btn-danger authorization" style="display: none" action-id="user-detail-pwd" action-name="修改密码"type="button" v-on:click="_UpdatePwd">修改密码</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

@section Scripts{
    <script type="text/javascript">

        var vm = new Vue({
            el: 'body',
            data: {
                currentRow: {
                    UserName: '',
                    Phone: "",
                    OldPwd: "",
                    Pwd:""
                }
            },
            computed: {},
            ready: function () {
                auth();
            },
            methods: {
                _UpdateUserInfo: function () {
                    QQT.ajax('/Admin/Account/UpdateUserInfo',
                        'POST', vm.currentRow)
                        .done(function (response) {
                            swal("成功啦！", "更新成功!", "success");
                        });
                },
                _UpdatePwd: function () {

                    if (!vm.currentRow.OldPwd) {
                        swal({
                            title: "",
                            text: "请输入旧密码！",
                            type: "error"
                        });
                        return;
                    }
                    if (!vm.currentRow.Pwd) {
                        swal({
                            title: "",
                            text: "请输入新密码！",
                            type: "error"
                        });
                        return;
                    }

                    QQT.ajax('/Admin/Account/UpdatePwd',
                            'POST', vm.currentRow)
                        .done(function (response) {
                            swal("更新成功！", "请退出系统重新登录!", "success");
                            vm.currentRow.OldPwd = '';
                            vm.currentRow.Pwd = '';
                        });
                }
            }
        });



    </script>

}